import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  strict: true,
  state: {
    primaryInfo: {
      name: "张三",
      introduction: "一句话介绍自己,告诉HR选择你的理由",
      age: "20",
      yearOfWork: "1",
      phone: "13800138000",
      email: "13800138000@qq.com"
    },
    resumeItems: [
      {
        itemId: 1,
        itemName: "preference",
        isShow: false,
        isShowInPrimaryIfo: false,
        timestamp: "求职意向",
        icon: "el-icon-arrow-down",
        content: {
          intendedPosition: "意向岗位",
          intendedCity: "意向城市",
          intendedSalary: "薪资要求",
          entryTime: "入职时间"
        }
      },
      {
        itemId: 2,
        itemName: "education",
        isShow: true,
        timestamp: "教育背景",
        icon: "el-icon-arrow-down",
        content: [
          {
            school: "就读学校",
            major: "就读专业",
            studyTime: ["开始时间", "结束时间"],
            description:
              ""
          },
        ]
      },
      {
        itemId: 3,
        itemName: "experience",
        isShow: true,
        timestamp: "工作经验",
        icon: "el-icon-arrow-down",
        content: [
          {
            company: "工作公司",
            position: "工作岗位",
            workTime: ["开始时间", "结束时间"],
            description:
              "详细描述你的职责范围、工作任务及取得的成绩，工作经验的时间采取倒叙形式，最近经历写在前面，描述尽量具体简洁，工作经验的描述与目标岗位的招聘要求尽量匹配，用词精准。"
          },
          {
            company: "工作公司",
            position: "工作岗位",
            workTime: ["开始时间", "结束时间"],
            description:
              "详细描述你的职责范围、工作任务及取得的成绩，工作经验的时间采取倒叙形式，最近经历写在前面，描述尽量具体简洁，工作经验的描述与目标岗位的招聘要求尽量匹配，用词精准。"
          }
        ]
      },
      {
        itemId: 4,
        itemName: "program",
        isShow: true,
        timestamp: "项目经验",
        icon: "el-icon-arrow-down",
        content: [
          {
            progrom: "具体项目",
            position: "你的职责",
            programTime: ["开始时间", "结束时间"],
            description: "详细描述你负责的部分、工作任务及取得的成绩"
          },
          {
            progrom: "具体项目",
            position: "你的职责",
            programTime: ["开始时间", "结束时间"],
            description: "详细描述你负责的部分、工作任务及取得的成绩"
          }
        ]
      },
      {
        itemId: 5,
        itemName: "certificate",
        isShow: true,
        timestamp: "荣誉证书",
        icon: "el-icon-arrow-down",
        content: "",
      },
      {
        itemId: 6,
        itemName: "evaluation",
        isShow: true,
        timestamp: "自我评价",
        icon: "el-icon-arrow-down",
        content: ""
      }
    ],
    resumeUpdateLoading: false,
  },
  getters: {
    showItems: state => {
      return state.resumeItems.filter(item => item.isShow).filter(item => !item.isShowInPrimaryIfo);
    }
  },
  mutations: {
    handleChangePrimaryInfo(state, primaryInfoForm) {
      state.resumeUpdateLoading = true;
      state.primaryInfo.name = primaryInfoForm.name
      state.primaryInfo.introduction = primaryInfoForm.introduction
      state.primaryInfo.age = primaryInfoForm.age
      state.primaryInfo.yearOfWork = primaryInfoForm.yearOfWork
      state.primaryInfo.phone = primaryInfoForm.phone
      state.primaryInfo.email = primaryInfoForm.email
      state.resumeUpdateLoading = false;
    },
    handleChangePreference(state, preForm) {
      state.resumeUpdateLoading = true;
      state.resumeItems[0].isShow = preForm.isShow;
      state.resumeItems[0].isShowInPrimaryIfo = preForm.isShowInPrimaryIfo;
      state.resumeItems[0].content.intendedPosition = preForm.intendedPosition;
      state.resumeItems[0].content.intendedCity = preForm.intendedCity;
      state.resumeItems[0].content.intendedSalary = preForm.intendedSalary;
      state.resumeItems[0].content.entryTime = preForm.entryTime;
      state.resumeUpdateLoading = false;
    },
    handleChangeEdu(state, edu) {
      state.resumeUpdateLoading = true;
      state.resumeItems[1].content = edu.eduForm;
      state.resumeItems[1].isShow = edu.eduIsShow;
      state.resumeUpdateLoading = false;
    },
    handleChangeExp(state, exp) {
      state.resumeItems[2].content = exp.expForm;
      state.resumeItems[2].isShow = exp.expIsShow;
    },
    handleChangePro(state, pro) {
      state.resumeUpdateLoading = true;
      state.resumeItems[3].content = pro.proForm;
      state.resumeItems[3].isShow = pro.proIsShow;
      state.resumeUpdateLoading = false;
    },
    handleChangeCer(state, cer) {
      state.resumeUpdateLoading = true;
      state.resumeItems[4].content = cer.cerDescription;
      state.resumeItems[4].isShow = cer.cerIsShow;
      state.resumeUpdateLoading = false;
    },
    handleChangeEva(state, eva) {
      state.resumeUpdateLoading = true;
      state.resumeItems[5].content = eva.evaDescription;
      state.resumeItems[5].isShow = eva.evaIsShow;
      state.resumeUpdateLoading = false;
    }
  },
  actions: {

  }
})
